﻿
function initializePager(options) {
   /* options = options | { pageBarId: "",
        postUrl: "noticelist!query.action",
        searchArg: function (pageNo, pageSize) { return { pageNo: pageNo, pageSize: pageSize }; },
        pageNo: 1,
        pageSize: 10,
        callBack: function (data) { alert(data); }
    };*/
    var pageBarId = options.pageBarId;
    var actionUrl = options.postUrl;
    $(pageBarId).pagination({
        total: 1,
        pageList: [10],
        pageSize: options.pageSize | 10, 
        onSelectPage: function (pageNumber, pageSize) {
            $(pageBarId).pagination({ loading: true });
            $.post(actionUrl,
                 options.searchArg(),
                 function (data) {
                     options.callBack(eval($.toJSON(data)));
                     $(pageBarId).pagination({ loading: false,total: data.length });
                 }, "json");
            //alert('pageNumber:' + pageNumber + ',pageSize:' + pageSize); 
        }
    });
}

function searchDataFromServer(actionUrl, pageBarId, searchArg, callBack) {
    $.post(actionUrl, searchArg,
                 function (data) {
                     callBack(eval($.toJSON(data)));
                     $(pageBarId).pagination({ loading: false, total: data.length, pageNumber: 1 });
                 }, "json");
}